<%@page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8" %>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录界面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-4"></div>
            <div class="col-md-4">
                <p class="h1 text-center">录入成绩</p>
                <select class="form-control" v-model="stuScoreM.examType" @change="getSelected">
                    <option value="请选择课程" disabled selected hidden>请选择课程</option>
                    <option v-for="(classCourseM,i) in classCourseMs" :value="classCourseM.selectCourse">{{classCourseM.selectCourse}}</option>
                </select>
                <br>
                <div>
                    <input type="text" name="stuId" class="form-control" v-model="stuScoreM.stuId" placeholder="学号">
                </div>
                <br>
                <div>
                    <input type="text" name="term" class="form-control" v-model="stuScoreM.term" placeholder="学期">
                </div>
                <br>
                <div>
                    <input type="text" name="major" class="form-control" v-model="stuScoreM.major" placeholder="专业">
                </div>
                <br>
                <div>
                    <input type="text" name="name" class="form-control" v-model="stuScoreM.name" placeholder="姓名">
                </div>
                <br>
                <div>
                    <input type="number" name="courseGrade" class="form-control" v-model="stuScoreM.courseGrade" placeholder="分数">
                </div>
                <br>
                <button type="submit" @click="add()" class="btn btn-info btn-block" >提交</button>
            </div>
        <div class="col-md-4">
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
<script src="/static/js/vue.js"></script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',

        data: {
            name:'',
            stuScoreM: {
                examType: '请选择课程',
                stuId: '',
                term: null,
                major: null,
                name: '',
                courseGrade: null,
            },
            classCourseMs:[],
        },
        created(){
            this.stuScoreM.examType = '请选择课程';
        },
        methods: {
            getSelected(){
                console.log(this.stuScoreM.examType);
            }
            ,
            getName:function () {
                $.ajax({
                    url:'/demo/design/getClassCourse',
                    type:'GET',
                    data:{name:this.name},
                    dataType:'json',
                    success:function(result){
                        app.classCourseMs = result;
                    }
                });
            },
            add:function () {
                $.ajax({
                    url:'/demo/score/addscore',
                    type:'POST',
                    contentType:'application/json',
                    data:JSON.stringify(app.stuScoreM),
                    dataType:'json',
                    // data:{"stuInfo":this.stuInfo},
                    success:function(result){
                        this.result = result;
                        var url = '/demo/score/index4';
                        if(result.indexOf("成功")>=0){
                            window.location.href='/demo/stuInfo/success?result='+this.result+'&url=' + url;
                        }else{
                            window.location.href= '/demo/stuInfo/error?result='+this.result+'&url=' + url;
                        }
                    }
                });
            }
        }
    });

    $(function () {
        app.getName();
    })
</script>
</body>
</html>